
import Head from 'next/head'

<Head>
  <script>
    {
      `(function() {
         var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e60fb290e204e04c5cb6f79b0ac1e697";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
       })();`
    }
  </script>
</Head>

![LangChain](https://pica.zhimg.com/50/v2-56e8bbb52aa271012541c1fe1ceb11a2_r.gif)






HTML
===========================================================

本文介绍如何将HTML文档加载到我们可以向下使用的文档格式中。
 







```python
from langchain.document_loaders import UnstructuredHTMLLoader

```










```python
loader = UnstructuredHTMLLoader("example_data/fake-content")

```










```python
data = loader.load()

```










```python
data

```








```python
[Document(page_content='My First Heading\n\nMy first paragraph.', lookup_str='', metadata={'source': 'example_data/fake-content'}, lookup_index=0)]

```







 Loading HTML with BeautifulSoup4
 [#](#loading-html-with-beautifulsoup4 "Permalink to this headline")
-------------------------------------------------------------------------------------------------------



 We can also use BeautifulSoup4 to load HTML documents using the
 `BSHTMLLoader`
 . This will extract the text from the html into
 `page_content`
 , and the page title as
 `title`
 into
 `metadata`
 .
 







```python
from langchain.document_loaders import BSHTMLLoader

```










```python
loader = BSHTMLLoader("example_data/fake-content")
data = loader.load()
data

```








```python
[Document(page_content='\n\nTest Title\n\n\nMy First Heading\nMy first paragraph.\n\n\n', lookup_str='', metadata={'source': 'example_data/fake-content', 'title': 'Test Title'}, lookup_index=0)]

```








